from enum import Enum

class BizError(Exception):

    def __init__(self, status_code):
        self.err_code = status_code.code()
        self.err_msg = status_code.msg()


class StatusCode(Enum):
    # 使用枚举进行错误码和错误信息的对应
    OK = (200, 'ok')

    NOT_LOGIN = (1001, '请您先登录')
    NOT_LEVEL = (1002, '您还不是超级管理员')
    USER_PWD_ERR = (1003, '用户名或密码错误')
    ADMIN_ERR = (1004, '超级管理员不能删除')
    TEACHER_NOT_ACCOUNT = (1005, '此教师还没有账号')

    NOT_STUDENT_CODE = (2001, '学籍号不存在')
    NOT_CLASS_NAME = (2002, '班级不存在')
    NOT_LESSON_NAME = (2003, '科目不存在')
    NOT_TEACHER_ACCOUNT = (2004, '此教师还没有账号')


    STUDENT_CODE_EXIST = (3001, '学籍号已存在')
    CLASS_NAME_EXIST = (3002, '班级名称已存在')
    LESSON_NAME_EXIST = (3003, '科目名称已存在')
    TEACHER_ACCOUNT_EXIST = (3004, '老师账号已存在')

    NOT_TEACHER = (4001, '教师编号无效')
    NOT_CLASS = (4002, '班级编号无效')
    NOT_LESSON = (4003, '科目编号无效')
    NOT_STUDENT = (4004, '学生编号无效')
    NOT_ACCOUNT = (4004, '账号编号无效')

    SYS_ERR = (5000, '系统错误')
    NOT_PARAM = (5001, '参数不存在')
    PARAM_ERR = (5002, '参数错误')
    REQUEST_ERR = (5003, '请求方式错误')
    LENGTH_ERR = (5004, '分数超出范围')

    def code(self):
        return self.value[0]

    def msg(self):
        return self.value[1]
